//$URL: http://deveth0.googlecode.com/svn/trunk/demos/jersey-springsecurity/src/main/java/de/deveth0/demos/jerseyspringsecurity/rest/UserIdSecuredResource.java $
//$Id: UserIdSecuredResource.java 2 2012-10-23 18:30:23Z amuthmann@gmail.com $
package de.deveth0.demos.jerseyspringsecurity.rest;

import de.deveth0.demos.jerseyspringsecurity.security.annotations.RequireUserIdCheck;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * TThis resource can only be access by the user with the same ID as requested
 *
 * @author deveth0
 */
@Path("/userid/{id}")
public class UserIdSecuredResource {

  /**
   * produces a simple "welcome" for users accessing the right page.
   *
   * If user "admin" tries to access /userid/admin, he will see the welcome, if he tries to access /userid/user it will fail.
   *
   * http://localhost:8080/demos.jersey-springsecurity/rest/userid/{id}
   *
   * @return
   */
  @GET
  @Produces(MediaType.TEXT_PLAIN)
  @RequireUserIdCheck
  public String getWelcome(@PathParam("id") String id) {
    return "Welcome user " + id;
  }
}
